<?php

namespace App\Admin\Controllers;

use App\Models\CollArea;
use App\Models\CollPosition;
use App\Models\CompanyUser;
use App\Models\Product;
use App\Models\ProductAttrKey;
use App\Models\SweetnessList;
use App\Models\VipInfo;
use Encore\Admin\Controllers\AdminController;
use App\Admin\Actions\Post\Restore;
use App\Admin\Actions\Post\productSKUList;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;


class SweetnessListController extends AdminController
{
    protected $title = '甜度选项';

    protected function grid()
    {
        $grid = new Grid(new SweetnessList());

        $grid->column('name', __('名称'));

        $grid->disableFilter();
        $grid->disableExport();
        $grid->disableRowSelector();
        $grid->disableColumnSelector();

        $grid->actions(function ($actions) {
            // 去掉删除
            $actions->disableDelete();
        });

        return $grid;
    }

    protected function detail($id)
    {
        $show = new Show(SweetnessList::findOrFail($id));

        $show->field('name', __('名称'));

        $show->panel()
            ->tools(function ($tools) {
                $tools->disableDelete();
            });;

        return $show;
    }

    protected function form()
    {
        $form = new Form(new SweetnessList());

        $form->text('name', __('名称'))->required();

        $form->tools(function (Form\Tools $tools) {
            // 去掉`删除`按钮
            $tools->disableDelete();
        });

        $form->footer(function ($footer) {
            // 去掉`继续编辑`checkbox
            $footer->disableCreatingCheck();
        });

        return $form;
    }
}